package server;

/**
 * Http协议工具类，主要提供相应头信息，这里只针对200和404 的情况
 */
public class HttpProtocolUtil {

    /**
     * 为响应码200提供请求头信息
     * @return
     */
    public static String getHttpHeader200(long contentLength){
        return "HTTP/1.1 200 OK \n"+
                "Cotent-Type: text/html \n"+
                "Cotent-Length: "+contentLength+"\n"+
                "\r\n";
    }

    /**
     * 为响应码404提供请求头信息
     * @return
     */
    public static String getHttpHeader404(){
        String str404 = "<h1>404 not found</h1>";
        return "HTTP/1.1 404 NOT Found \n" +
                "Cotent-Type: text/html \n" +
                "Cotent-Length: " + str404.getBytes().length + "\n" +
                "\r\n"+str404;
    }

}
